package com.training.java.core.homework02;

public class Calculator {

	// Variables
	private double amount1;
	private double amount2;
	private double result;
	private double remainder;

	// Methods
	public Calculator(double result, double amount1, double amount2,
			double remainder) {
		this.amount1 = 0;
		this.amount2 = 0;
		this.result = 0;
		this.remainder = 0;
	}

	// Method calculate with 3 parameters.
	public void claculate(double amount1, double amount2, char operator) {

		switch (operator) {
		case '+':
			add(amount1, amount2);
			break;

		case '-':
			subtract(amount1, amount2);
			break;

		case '*':
			multiply(amount1, amount2);
			break;

		case '/':
			divide(amount1, amount2);
			break;

		case '%':
			break;
		}
	}

	// Method calculate with 2 parameters overloads the one with 3 parameters.
	public void claculate(double amount1, char operator) {

		switch (operator) {
		case '+':
			add(amount1);
			break;

		case '-':
			subtract(amount1);
			break;

		case '*':
			multiply(amount1);
			break;

		case '/':
			divide(amount1);
			break;

		case '%':
			break;
		}
	}

	private void add(double amount1, double amount2) {
		this.result = amount1 + amount2;
	}
	
	// Overloads previous
	private void add(double amount1) {
		this.result += amount1;
	}

	public void subtract(double amount1, double amount2) {
		this.result = amount1 - amount2;
	}

	// Overloads previous
	public void subtract(double amount1) {
		this.result -= amount1;
	}

	public void multiply(double amount1, double amount2) {
		this.result = amount1 * amount2;
	}

	// Overloads previous
	public void multiply(double amount1) {
		this.result *= amount1;
	}

	public void divide(double amount1, double amount2) {
		this.remainder = amount1 % amount2;
		this.result = amount1 / amount2;
	}

	// Overloads previous
	public void divide(double amount1) {
		this.remainder = this.result % amount1;
		this.result /= amount1;
	}

	// Getters
	public double getAmount1() {
		return this.amount1;
	}

	public double getAmount2() {
		return this.amount2;
	}

	public double getResult() {
		return this.result;
	}

	public double getRemainder() {
		return this.remainder;
	}
}
